package part10;

/**
 * @author wcj
 * @Date 2021/5/19 18:03
 * @Version 1.0
 */
public class Part108 {

    private int j = 10;
    private static String test = "kkk";

    private class CopyCup implements Cup {
        // 普通的内部类中不能含有静态成员和方法甚至静态内部类
//        private static int i = 10;
        private int i = 10;

        @Override
        public int value() {
            return i;
        }
    }

    private static class CopyBeg implements Beg {
        private String label;

        public CopyBeg(String s) {
            this.label = s;
        }

        @Override
        public String readLabel() {
            return label;
        }

        // 静态内部类中能含有静态成员
        private static int i = 10;

        public static String f() {
            return test;
        }

        public int g() {
            // 静态内部类中不能访问外部类的非静态成员，这是因为静态内部类中没有捕获外部类的对象引用
//            return j;
            return i;
        }

        static class hhh {
        }
    }

    public Cup cup() {
        return new CopyCup();
    }

    public static Beg beg(String s) {
        return new CopyBeg(s);
    }

    public static void main(String[] args) {
        Part108 part108 = new Part108();
        Cup cup = part108.cup();
        Beg hhh = beg("hhh");
    }
}

interface Cup {

    /**
     * value
     *
     * @return
     */
    int value();
}

interface Beg {

    /**
     * readLabel
     *
     * @return
     */
    String readLabel();
}
